from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from database import ORM

Base = declarative_base()


class WeiboRecord(Base):
    __tablename__ = 'weibo_record'

    id = Column(BigInteger, primary_key=True)

    # 微博内容全文
    detail = Column(String(1000))

    # 每条微博对应的id
    mid = Column(String(50))

    # 每条微博对应的详情页链接
    url = Column(String(250))

    # 转发数
    repost_num = Column(Integer)

    # 评论数
    comment_num = Column(Integer)

    # 点赞数
    thumps_num = Column(Integer)

    # 微博发布时间
    create_time = Column(DateTime)

    # 博主在微博中对应的user id
    weibo_uid = Column(BigInteger)

    # 发布微博时使用的设备
    device = Column(String(250))

    # 标记是否提取详情内容
    is_extract_detail = Column(bool)

    # 标记是否提取详评论
    is_extract_comments = Column(bool)


class WeiboComment(Base):
    id = Column(BigInteger, primary_key=True)

    w_id = Column(BigInteger)

    from_uid = Column(BigInteger)

    to_uid = Column(BigInteger)

    content = Column(String(250))

    create_time = Column(DateTime)


orm = ORM('mysql+mysqlconnector://root:123456@localhost:3306/spider_data', Base)
Session = sessionmaker(orm.engine)
